package com.gitee.lw114514.webapp_memorandium.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.gitee.lw114514.webapp_memorandium.pojo.Task;
import com.gitee.lw114514.webapp_memorandium.service.GetService.GetService;

import java.util.List;

@RestController
@CrossOrigin(origins = {"http://localhost:5500", "http://127.0.0.1:5500"}, allowCredentials = "true", allowedHeaders = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.OPTIONS})
public class GetTaskController {
    //1.引入service层
    @Autowired
    private GetService getService;

    //2.处理请求
    @RequestMapping("/api/complete_task")
    public List<Task> completeTaskList() {
        //3.调用service层，获取数据
        List<Task> taskList = getService.findAllCompleteTask();
        //4.返回数据json
        return taskList;
    }

    @RequestMapping("/api/uncomplete_task")
    public List<Task> uncompleteTaskList() {
        //3.调用service层，获取数据
        List<Task> taskList = getService.findAllUncompleteTask();
        //4.返回数据json
        return taskList;
    }
}
